<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Admin_Model_HospitalDetail extends ZF_DB{
    protected $_table_name = "hospital_detail" ;
    
    protected $_id;
    protected $_name;
    protected $_name_en;
    protected $_description;
    protected $_description_en;
    protected $_address;
    protected $_city;
    protected $_phone;
    protected $_images;
    protected $_view_counter;
    protected $_rate;
    protected $_active;
    
    public function getName(){
        return $this->_name;
    }
    public function setName($name){
        $this->_name = $name;
    }
    public function getNameEn(){
        return $this->_name_en;
    }
    public function setNameEn($name_en){
        $this->_name_en = $name_en;
    }
    public function getDescription(){
        return $this->_description;
        
    }
    public function setDescription($description){
       $this->_description = $description;
        
    }
    public function getDescriptionEn(){
        return $this->_description_en;
        
    }
    public function setDescriptionEn($description_en){
        $this->_description_en = $description_en;
    }
    public function getCity(){
        return $this->_city;
    }
    public function setCity($city){
        $this->_city = $city;
    }
    public function getPhone(){
        return $this->_phone;
    }
    public function setPhone($phone){
        $this->_phone = $phone;
    }
    public function getImages(){
        return $this->_images;
        
    }
    public function setImages($images){
        $this->_images = $images;
    }
    public function getCounter(){
        return $this->_counter;
    }
    public function setCounter($counter){
        $this->_counter = $counter;
    }
    public function getRate(){
        return $this->_type;
    }
    public function setRate($rate){
        $this->_rate = $rate;
    }
   public function setAddress($address){
       $this->_address = $address;
   }
   public function getAddress(){
       return $this->_address;
   }
    public function getId(){
        return $this->_id;
    }
    public  function setId($id){
        $this->_id = $id;
    }
   
    public function getActive(){
        return $this->_active;
    }
    public function setActive($active){
        $this->_active = $active;
    }
 
    
    public function insert($name,$name_en,
            $description = "",$description_en = "",
            $phone ="",$city = 0,$address ="",
            $images ="",
            $rate = 0,$counter = 0,$active=1){
        
        if($name){             
                $data =  array(
                    'name' =>$name,
                    'name_en'=>$name_en,
                    'description' =>$description,
                    'description_en'=>$description_en,
                    'images'=>$images,
                    'rate'=>$rate,
                    'phone'=>$phone,
                    'address'=>$address,
                    'counter'=>$counter,
                    'city' =>$city,
                    'active'=>$active);
            return         $this->db->insert($this->_table_name,$data);
	
	}
        return -1;
	
    }
   
    public function update(){
        $where  = "id = $this->_id";
	$data =  array(
                    'name' =>$this->_name,
                    'name_en'=>$this->_name_en,
                    'address' =>$this->_address,
                    'phone'=>$this->_phone,
                    'description'=>$this->_description,
                    'description_en'=>$this->_description_en,
                    'city'=>$this->_city,
                    'rate'=>$this->_rate,
                    'images'=>$this->_images,
                    'counter' =>$this->_counter,
                    'active'=>$this->_active);
        
	return $this->db->update(
                $this->_table_name,
                $data,$where);
    }
    public function getById($id){
        if($id)
	{
		$select = $this->db->select()
			->from(array("p"=>$this->_table_name))
                        ->where("p.id = ?",$id );
		
		$data = $this->db->fetchRow($select);
		if($data){
			$this->_id = $data['id'];
			$this->_name = $data['name'];
			$this->_name_en = $data['name_en'];
			$this->_address = $data['address'];
                        $this->_phone = $data['phone'];       
                        $this->_city = $data['city'];
                        $this->_description = $data['description'];
                        $this->_description_en = $data['description_en'];
                        $this->_rate = $data['rate'];
                        $this->_counter = $data['counter'];
                        $this->_images = $data['images'];
                        $this->_active = $data['active'];
			
		}
                return $data;
	}
	return -1;
    }
   
    public function listAll(){
        
        $select = $this->db->select()
                ->from($this->_table_name)
                ->where("active = ?",1);
	$data = $this->db->fetchAll($select);
	return $data;
    }
    public function delete(){
            $this->getById($this->_id);
            $this->_active = 0;
            return $this->update();
    }
}
?>
